var member_id = '',
	xid,
	ws;
document.addEventListener('plusready',function(){
	member_id = plus.storage.getItem('id');
	ws = plus.webview.currentWebview();
	goods_id = ws.xid;
	spage = ws.spage;
//	console.log(xid+'--'+member_id);
	plus.nativeUI.showWaiting('加载中...');
	$.ajax({  
		type:"post", 
		url:apiRoot+"?act=member_campus&op=onedetails",
		data:{member_id:member_id,xid:goods_id},
		dataType:'json',
		success:function(data){ 
			console.log(JSON.stringify(data.datas)); 
			if(data.code == 200){ 
//				console.log(member_id +'--'+ data.datas.member_id);
				if(member_id == data.datas.member_id){
					$('.zhuangtai2').css('display','block');
				}else{
					$('.tel').attr('data-tel',data.datas.publisher.member_mobile);
					$('.zhuangtai1').css('display','block');
					$('.touxiang').attr('src',(data.datas.publisher.member_avatar != null?(user_pic + data.datas.publisher.member_avatar):"../public/img/pic_img.jpg"));
					$('.member_naem').text(data.datas.publisher.member_truename);
				}
				$('.campus_time').text(data.datas.qtime);
				$('.campus_title').text(data.datas.title);
				$('.campus_datatime').text(data.datas.targettime);
				$('.campus_lxr').text(data.datas.contacts);
				$('.campus_price').text('￥' + data.datas.remuneration);
				$('.campus_address').text(data.datas.address);
				$('.campus_tel').text(data.datas.publisher.member_name);
				$('.campus_xq').text(data.datas.demand);
				if(data.datas.campus_pics){	 
					var html = ''; 
					$.each(data.datas.campus_pics, function(k,v) {
						html += '<img src="'+ app_pic + data.datas.publisher.member_id + '/' + v +'" data-preview-src="" data-preview-group="1"/>';
					});
					$('.campus_pic').html(html);
				}
			}
			plus.nativeUI.closeWaiting();
			if(member_id == data.datas.member_id){
				$('.benren').css('display','block');
			}else{
				$('.yonghuo').css('display','block');
			}
			
			$('.order1').on('click',function(){
				$.ajax({ 
					type:"post",
					url:apiRoot + "?act=member_campus&op=accept",
					data:{member_id:member_id,xid:goods_id},
					dataType:'json',
					success:function(data){
						console.log(JSON.stringify(data));
						if(data.code == 200){
							toast('接受成功');
							plus.webview.getWebviewById(spage).reload();
							setTimeout(function(){
								ws.close();
							},500)
						}else{
							toast(data.datas.error);
						}
					},
					error:function(e){
						error();
						
					}
				});
			})
			
			$('.order2').on('click',function(){
//				console.log(apiRoot + "?act=member_campus&op=task_cancel--"+member_id+'--'+xid);return;
				$.ajax({  
					type:"post",
					url:apiRoot + "?act=member_campus&op=task_cancel",
					data:{member_id:member_id,xid:goods_id},
					dataType:'json',
					success:function(data){
//						console.log(JSON.stringify(data));
						if(data.code == 200){
							toast('取消成功');
							plus.webview.getWebviewById(spage).reload();
							setTimeout(function(){
								ws.close();
							},500)
						}else{
							toast(data.datas.error);
						}
					},
					error:function(e){
						console.log(JSON.stringify(e));
						
					}
				});
			})
		},  
		error:function(e){
			plus.nativeUI.closeWaiting();
			toast('连接失败！');
		}
	});
},false);